package com.example.wechatlistview.resmanager;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;

import androidx.annotation.ArrayRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;

import java.lang.reflect.Array;

/**
 * 资源管理类
 * 资源id -> 对应类型资源
 */
public class DataSource {
    private Context context;

    public DataSource(Context context) {
        this.context = context;
    }


    public String GetStrFromRes(@StringRes int id) {
        return this.context.getResources().getString(id);
    }

    public String[] GetStrArrayFromRes(@ArrayRes int id) {
        return this.context.getResources().getStringArray(id);
    }

    public Drawable GetDrawableFromRes(@DrawableRes int id) {
        return this.context.getResources().getDrawable(id);
    }

    //region Static Classes

    public static String GetStrFromRes(@NonNull Context context, @StringRes int id) {
        return context.getResources().getString(id);
    }

    public static String[] GetStrArrayFromRes(@NonNull Context context, @ArrayRes int id) {
        return context.getResources().getStringArray(id);
    }

    public static Drawable GetDrawableFromRes(@NonNull Context context, @DrawableRes int id) {
        return context.getResources().getDrawable(id);
    }

    //endregion


}
